package net.mysgame.czfun.service;

import net.mysgame.czfun.module.user.data.CzUser;
import net.mysgame.czfun.module.user.store.CzUserMapper;
import net.mysgame.czfun.utils.IdUtils;
import org.apache.shiro.authz.annotation.RequiresUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * Created by manatea on 2016/5/19.
 */
@Service
public class UserService {
    private static final Logger log = LoggerFactory.getLogger(UserService.class);

    @Autowired
    private CzUserMapper czUserMapper;

    public CzUser getUserByName(String name) {
        long id = IdUtils.generateUserId(name);
        return czUserMapper.getUserById(id);
    }

    @RequiresUser
    public String loginMove(){
        System.out.println("this is a move");
        return "this is a move";
    }

    public boolean addOrUpdateUser(CzUser czUser) {
        return czUserMapper.addOrUpdateUser(czUser);
    }
}
